package likou;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2020/12/27 07:01
 */
public class _205 {
    public static void main(String[] args) {
        System.out.println(isIsomorphic("egg","add"));
    }
    public static boolean isIsomorphic(String s, String t) {
        if(s.length()!=t.length()){
            return false;
        }
        Map<Integer,Integer> map = new HashMap<>();
        byte[] sb = s.getBytes();
        byte[] tb = t.getBytes();
        for(int i=0;i<sb.length;i++){
            int now = map.getOrDefault((int) sb[i],0);
            System.out.println(now+" "+sb[i]+" " +tb[i]);
            if(now==0){
                for(Integer key:map.keySet()){
                    if(tb[i]==map.get(key)){
                        return false;
                    }
                }
                map.put((int) sb[i], (int) tb[i]);//映射关系
                System.out.println(map.get((int) sb[i]));
            }else{
                if(now!=tb[i]){
                    return false;
                }
            }
        }
        return true;
    }
}
